﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.SqlClient;
using System.Collections;


namespace EZCRS.HCMS.Bll.baseinfo
{
    /// <summary>
    /// 选择框内容分类
    /// </summary>
    public enum baseinfotype :int
    {
        房型种类=34,床型,房型其他,酒店图片类型,税金类型,税金种类,税金频率,保证金类型措施,保证金时期,取消制度罚金类型,货币金额类型,消息发送类型,消息接收方式,房间状态=66,价格代码类别,价格代码种类
    }

    public class Bllbase_info
    {
        
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page">当前页数</param>
        /// <param name="pagecount">总页数</param>
        /// <param name="swhere">查询条件</param>
        /// <returns></returns>
        public List<HCRS_Baseinfo> getallbypage(int page, out int pagecount, string swhere)
        {
            //查询条件
            string strwhere = "";

            return new sql_hcrs_baseinfo().getallbypage(page, strwhere, out pagecount);
        }

        /// <summary>
        /// 获得所有符合条件的记录
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List<HCRS_Baseinfo> getitem(string search)
        {
            string sqlwhere = search;
            return new sql_hcrs_baseinfo().getall(sqlwhere);
        }

        /// <summary>
        /// 获得单项值
        /// </summary>
        /// <param name="types">类别</param>
        /// <param name="languagetype">语言</param>
        /// <returns></returns>
        public static List<dropdowndata> getbaseinfo(baseinfotype _type, int languagetype)
        {
            string typeid = Enum.Format(typeof(baseinfotype), _type, "d");
            HCRS_Baseinfo _binfo=new Bllbase_info().getitem(Convert.ToInt32(typeid));
            List<HCRS_Baseinfo> _info=null;
            if (_binfo.code == "0")
                _info = new Bllbase_info().getitem("  type=" + typeid + " and languagetype="+languagetype.ToString()+" ");
            else
                _info = new Bllbase_info().getitem(" pid="+CFun.GetCookies("cms","p")+" and type=" + typeid + " and languagetype="+languagetype.ToString()+" ");

            List<dropdowndata> _list = new List<dropdowndata>();
            foreach (HCRS_Baseinfo _item in _info)
            {
                _list.Add(new dropdowndata(_item.code,_item.name));
            }
            return _list;
        }

      
        /// <summary>
        /// 获得单项值
        /// </summary>
        /// <param name="types">类别</param>
        /// <param name="languagetype">语言</param>
        /// <returns></returns>
        public static List<dropdowndata> getbaseinfoid(baseinfotype _type, int languagetype)
        {
            List<HCRS_Baseinfo> _info = new Bllbase_info().getitem(" type=" + Enum.Format(typeof(baseinfotype), _type, "d") + " ");

            List<dropdowndata> _list = new List<dropdowndata>();
            foreach (HCRS_Baseinfo _item in _info)
            {
                _list.Add(new dropdowndata(_item.id.ToString() + "|" + _item.code, _item.name));
            }
            return _list;
        }


        /// <summary>
        /// 获得一条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HCRS_Baseinfo getitem(int id)
        {
            return new sql_hcrs_baseinfo().getitem(id);
        }

        #region 删除
        /// <summary>
        /// 删除一条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool deleteitem(int id)
        {
            return new sql_hcrs_baseinfo().deleteitem(id);
        }

        /// <summary>
        /// 删除一系列数据
        /// </summary>
        /// <param name="idlist"></param>
        /// <returns></returns>
        public bool deleteitem(string idlist)
        {
            return new sql_hcrs_baseinfo().deleteitem(idlist);
        }
        #endregion

        /// <summary>
        /// 添加或修改
        /// </summary>
        /// <param name="_log"></param>
        /// <returns></returns>
        public bool insertorupdateitem(HCRS_Baseinfo _log)
        {
            return new sql_hcrs_baseinfo().insertorupdate(_log);
        }


    }
}
